package xyz.mantianx.service;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * @author starrysky
 * @title: DynNacs
 * @projectName spring5
 * @description: TODO
 * @date 2021/2/302:33
 */
@Component
@Aspect
public class DynNacs {

    @Before("execution(* xyz.mantianx.service.HumanImpl.*(..))")
    public void before(){
        System.out.println("=============前置");
    }

    @After("execution(* xyz.mantianx.service.HumanImpl.*(..))")
    public void after(){
        System.out.println("=============之后");
    }

    /**
     * 环绕增强
     */
    @Around("execution(* xyz.mantianx.service.HumanImpl.*(..))")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环前");
        Object proceed = proceedingJoinPoint.proceed();
        System.out.println("环后");
    }
}
